package io;

import java.io.*;

public class BufferReadWriterTest {
    public static void main(String[] args) {
        FileWriter fileWriter = null;
        FileReader fileReader=null;
        BufferedWriter bufferedWriter=null;
        BufferedReader bufferedReader=null;
        try {
            char[] chars = new char[1024];
            int count=0;
            String data;
            fileWriter = new FileWriter("d:/2.txt");
             fileReader = new FileReader("d:/1.txt");
             bufferedWriter = new BufferedWriter(fileWriter);
             bufferedReader = new BufferedReader(fileReader);
            if((count=bufferedReader.read(chars))!=-1){
                bufferedWriter.write(chars,0,count);
            }
//            while ((data=bufferedReader.readLine())!=null){
//                bufferedWriter.write(data);
//                bufferedWriter.newLine();
//            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                bufferedWriter.flush();
                fileWriter.flush();
                bufferedReader.close();
                fileReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
